<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <link rel="stylesheet" href="{{ tem_obj.tem }}/css/index.css">
    <!-- 弹窗样式css -->
    <link rel="stylesheet" href="{{ tem_obj.tem }}/css/dialog.css">
{#    <script src="{{ tem_obj.tem }}/js/index.js"></script>#}
    <script src="{{ tem_obj.tem }}/js/jquery.js"></script>
    <!-- 弹窗样式js -->
    <script src="{{ tem_obj.tem }}/js/dialog.js"></script>
    <script src="{{ tem_obj.tem }}/js/clipboard.min.js"></script>
    <!-- 基础代码 -->
    {{ tem_obj.base_js | safe }}
    
</head>
<body>
    <h1>标签模板</h1>

    <p>cnzz:{{ tem_obj.cnzz }}</p><!-- cnzz号码 -->
    <p>wx:{{ tem_obj.wx | safe }}</p><!-- 微信号 -->
    <p>tem:{{ tem_obj.tem }}</p><!-- css/img/js... 等路径 -->
    <p>copyright_:{{ tem_obj.copyright_ }}</p><!-- 版权 -->
    <p>base_js:{{ tem_obj.base_js | safe }}</p><!-- 基础代码 -->
    <p>transfer:{{ tem_obj.transfer | safe }}</p><!-- 调用代码 -->
    <p>third_api:{{ tem_obj.third_api | safe }}</p><!-- 第三方api -->
    <p>path_url:{{ tem_obj.path_url | safe }}</p><!-- 外部链接 -->
    <!-- 使用js方式加载二维码 需要按顺序加载
    <script> document.write(wx_img); </script>-->
    <div class="div1"></div>
    <div class="div2"></div>

    <!-- 使用html方式加载二维码，可放在p  span  font标签中 -->
    <div class="qr"></div>

    <!-- js方式需要按顺序加载
    <p>js方式显示wx：<span style="color: red" id="copy_wx"><script> document.write(stxlwx);</script></span></p>-->
    <p>使用html来显示wx：<span id="copy_wx" class="html_wx"></span></p>
    <button id="btn" data-clipboard-target="#copy_wx">点击复制微信号</button>


    <script type="text/javascript">
        // 获取url某个参数
        function getQueryVariable(variable){
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
            }
            return '';
        }

        var clickid = getQueryVariable('clickid');  // 获取url某个参数
        // 前端显示表单
        var wfheight='700'; //订单高度
        var wfsrc="{{ tem_obj.third_api | safe }}?clickid=" + clickid ;
    　　document.write('<iframe src="'+wfsrc+'" width="100%" height="'+wfheight+'" frameborder="0" scrolling="no"></iframe>');

    </script>
    <script>

        $(function () {
            // 添加微信处
            var arr_wx ={{ tem_obj.wx | safe }};  // 微信号
            var wx_index = Math.floor((Math.random() * arr_wx.length));
            var stxlwx = arr_wx[wx_index];
            var img = "{{ tem_obj.path_url }}" + stxlwx + ".jpg";
            var wx_img = "<img width='300' height='300' src='" + img + "'>";

            // 使用html=方式加载二维码
            $('.qr').append('<img src="{{ tem_obj.path_url }}'+stxlwx+'.jpg" alt="" class="js-wximg wxcode">');
            $(".html_wx").html(stxlwx);

            //声明_czc对象:
            var _czc = _czc || [];
            //绑定siteid，请用您的siteid替换下方"XXXXXXXX"部分
            _czc.push(["_setAccount", "{{ tem_obj.cnzz }}"]);

            var clipboard = new ClipboardJS('#btn');
            clipboard.on('success', function(e) {

                $(document).dialog({
                    type: 'confirm',
                    closeBtnShow: true,
                    overlayClose: true,
                    content: '微信号复制成功，立刻为你打开微信',
                    onClickConfirmBtn: function() {
                        {{ tem_obj.transfer | safe }}
                        _czc.push(["_trackEvent", '点击复制内容', "复制并跳转", stxlwx]);
                        // 媒体平台回调代码在这里编写
                        window.location.href = 'weixin://';
                    }
                });
            });

            clipboard.on('error', function(e) {
                alert('复制失败，请长按手动复制！');
            });

            {#document.body.oncopy = function () {#}
            {#    window.location.href = 'weixin://';#}

            {#document.getElementById('copy_wx').oncopy = function () {
                abc()
            };#}
            function abc(){
                _czc.push(["_trackEvent", '长按复制内容', "复制", stxlwx]);
                // 媒体平台回调代码在这里编写
                alert('复制微信号：' + stxlwx);
                window.location.href = "weixin://"
            }
        });

    </script>

<script src="https://s19.cnzz.com/z_stat.php?id={{ tem_obj.cnzz }}&web_id={{ tem_obj.cnzz }}" language="JavaScript"></script>
</body>
</html>